
    <title>到付核销</title>
    <style>
        .layui-form-select .layui-input {
            padding-right: 0px;
            cursor: pointer;
        }
    </style>

<div class="layui-fluid" style="padding: 15px">
    <div class="layui-row layui-col-space15">
        <div class="layui-col-md12">
            <div class="layui-card">
                <div class="layui-card-header" style="height: 230px">
                    <form class="layui-form layui-form-pane" action="#" lay-filter="example">
                        <div class="layui-col-md3">
                            <div class="layui-form-item">
                                <label class="layui-form-label">托运单号：</label>
                                <div class="layui-inline">
                                    <input name="waybill_id" class="layui-input" id="forwardingunit" autocomplete="off">
                                </div>
                            </div>
                        </div>
                        <div class="layui-col-md3">
                            <div class="layui-form-item">
                                <label class="layui-form-label"> 出发地： </label>
                                <div class="layui-inline">
                                    <input name="city" class="layui-input" autocomplete="off">
                                </div>
                            </div>
                        </div>
                        <div class="layui-col-md3">
                            <div class="layui-form-item">
                                <label class="layui-form-label">到达分站：</label>
                                <div class="layui-inline">
                                    <select name="sub_id" id="substationUnit">
                                        <option value="">请选择出发站</option>
                                    </select>
                                </div>
                            </div>
                        </div>
                        <div class="layui-col-md3">
                            <div class="layui-form-item">
                                <label class="layui-form-label">到达城市：</label>
                                <div class="layui-inline">
                                    <input  class="layui-input" name="arrivalCity" autocomplete="off" >
                                </div>
                            </div>
                        </div>
                        <div class="layui-col-md3">
                            <div class="layui-form-item">
                                <label class="layui-form-label">收货单位：</label>
                                <div class="layui-inline">
                                    <input  class="layui-input" name="eeforwardingUnit" autocomplete="off" >
                                </div>
                            </div>
                        </div>
                        <div class="layui-col-md3">
                            <div class="layui-form-item">
                                <label class="layui-form-label">发货单位：</label>
                                <div class="layui-inline">
                                    <input  class="layui-input" name="forwardingUnit" autocomplete="off" >
                                </div>
                            </div>
                        </div>
                        <div class="layui-col-md3">
                            <div class="layui-form-item">
                                <label class="layui-form-label">发货日期：</label>
                                <div class="layui-inline">
                                    <input type="date"  name="date"  placeholder="yyyy-MM-dd" autocomplete="off" class="layui-input">
                                </div>
                            </div>
                        </div>
                        <div class="layui-col-md3">
                            <div class="layui-form-item">
                                <label class="layui-form-label">付款方式：</label>
                                <div class="layui-inline">
                                    <select name="paymentMethod">
                                        <option value="">请选择</option>
                                        <option value="支付宝">支付宝</option>
                                        <option value="微信">微信</option>
                                        <option value="现金">现金</option>
                                        <option value="刷卡">刷卡</option>
                                    </select>
                                </div>
                            </div>
                        </div>
                        <div class="layui-col-md3">
                            <div class="layui-form-item">
                                <label class="layui-form-label">核销状态：</label>
                                <div class="layui-inline">
                                    <select name="verification">
                                        <option value="">请选择</option>
                                        <option value="false">false</option>
                                        <option value="ture">ture</option>
                                    </select>
                                </div>
                            </div>
                        </div>
                        <div class="layui-col-md3">
                            <div class="layui-form-item">
                                <label class="layui-form-label">订单状态：</label>
                                <div class="layui-inline">
                                    <select name="state">
                                        <option value="">请选择</option>
                                        <option value="未装载">未装载</option>
                                        <option value="装车完毕">装车完毕</option>
                                        <option value="待卸货">待卸货</option>
                                        <option value="卸货完毕">卸货完毕</option>
                                        <option value="派送中">派送中</option>
                                        <option value="运输外包中">运输外包中</option>
                                        <option value="已签收">已签收</option>
                                    </select>
                                </div>
                            </div>
                        </div>
                        <div class="layui-col-md3">
                            <div class="layui-form-item">
                                <button type="button"  class="layui-btn layui-btn-sm" lay-submit lay-filter="souSuo">搜索数据</button>
                            </div>
                        </div>
                    </form>
                </div>
                <div class="layui-card-body">
                    <table id="consigner" lay-filter="consignerTable"></table>
                </div>
            </div>
        </div>
    </div>
</div>
<!--菜单工具栏-->
<script type="text/html" id="toolbarMenu">
    <div class="layui-btn-container">
        <button class="layui-btn layui-btn-sm" lay-event="addMenutble">运单到付核销</button>
    </div>
</script>
<script>
    layui.use(['form','jquery','table'], function() {
        var form = layui.form;
        var $ = layui.jquery;
        var table = layui.table;

        form.render();
        //动态新增下拉框
        $.ajax({
            url: "../../getAllSubstation",
            type: "post",
            data: {},
            dataType: "json",
            success: function (data) {
                //动态添加下拉框
                for (var i = 0; i < data.length; i++) {
                    $("#substationUnit").append("<option value='" + data[i].subId + "'>" + data[i].subName + "</option>");
                }
                //刷新
                form.render('select')
            }
        })




        //菜单表格
        table.render({
            elem: '#consigner'
            ,height: 500
            ,id:'consignerTable'
            ,url: '../../FinancingControllerGetAllFinancing' //数据接口
            ,toolbar: '#toolbarMenu' //开启头部工具栏，并为其绑定左侧模板
            ,limit:8
            ,limits:[8,16,24,32]
            ,defaultToolbar: ['filter', 'exports', 'print', { //自定义头部工具栏右侧图标。如无需自定义，去除该参数即可
                title: '提示'
                ,layEvent: 'LAYTABLE_menu'
                ,icon: 'layui-icon-tips'
            }]
            ,page: true //开启分页
            ,cols: [[ //表头
                {type: 'checkbox', fixed: 'left'}
                ,{field: 'waybill_id',width:180, title: '运单id'}
                ,{field: 'consignDate',width:220,title: '发货日期'}
                ,{field: 'city', width:120,title: '出发地'}
                ,{field: 'arrivalCity',width:120, title: '达到城市'}
                ,{field: 'forwardingUnit',width:180, title: '发货单位'}
                ,{field: 'state',width:120, title: '运单状态'}
                ,{field: 'descriptionGoods', width:260,title: '货物名称'}
                ,{field: 'quantity',width:120, title: '货物数量'}
                ,{field: 'weight',width:120, title: '货物重量'}
                ,{field: 'volume',width:120, title: '货物体积',}
                ,{field: 'cost',width:120, title: '基本运费'}
                ,{field: 'picUpCharge',width:120, title: '提货费'}
                ,{field: 'deliveryFee', width:120,title: '送货费'}
                ,{field: 'premium',width:120, title: '保险费'}
                ,{field: 'aggregateAmount',width:120, title: '总费用'}
                ,{field: 'paymentMethod',width:120, title: '付款方式'}
                ,{field: 'nowClosed',width:120, title: '现收'}
                ,{field: 'freightCollect',width:120, title: '到付'}
                ,{field: 'eeforwardingUnit', width:220,title: '收货单位'}
                ,{field: 'tms_name', width:120,title: '开单人'}
                ,{field: 'verification',width:120, title: '是否核销'}
            ]]
        })






        //角色头部工具栏头工具栏事件
        table.on('toolbar(consignerTable)', function(obj){
            var checkStatus = table.checkStatus(obj.config.id);

            var data = checkStatus.data;
            if (data.length==0){
                alert("请选择一行")
            } else if (data.length>1){
                alert("只能选中一行")
            }else {
                switch(obj.event) {
                    case 'addMenutble':
                        //iframe层
                            layer.open({
                                type: 2,
                                title: '是否核销',
                                shadeClose: true,
                                shade: 0.8,
                                area: ['1000px', '50%'],
                                content: '/src/views/finance/iframe/updatefinancing.html?id=' + data[0].waybill_id //iframe的url
                            });
                            break;
                };
            }
        });












        //提交数据
        form.on('submit(souSuo)', function(data){
            //执行重载
            table.reload('consignerTable', {
                page: {
                    curr: 1 //重新从第 1 页开始
                }
                //根据条件查询
                ,where: data.field
            });
            return false; //阻止表单跳转。如果需要表单跳转，去掉这段即可。
        });
    })
</script>